﻿using System.IO;
using FANN.Net;

namespace Сlassifier_Tool_For_OpenCV
{
    public class Item
    {
        public int Index;
        public string F;
        public double Value;
        private string _file;
        public Item(int ind, double value, NeuralNet net, string file)
        {
            _file = file;
            Index = ind;
            Value = value;
            Directory.CreateDirectory(Path.GetDirectoryName(file) + "\\temp\\");
            F = Path.GetDirectoryName(file) + "\\temp\\" +
                Path.GetFileNameWithoutExtension(file) + " " + ind + " " + value + ".ann";
            net.Save(F);
        }

        public Item(int ind, double value, string file)
        {
            Index = ind;
            Value = value;
            F = file;
        }

        public void Save(string patch)
        {
            if (File.Exists(patch))
                File.Delete(patch);
            File.Copy(F, patch);
        }

        public void TempSave()
        {
            File.Copy(F, Path.GetDirectoryName(_file) + "\\temp\\" +
                         Path.GetFileNameWithoutExtension(_file) + ".ann",true);
        }

    }
}